package com.lesson00;


import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TestPanel {
    public static void main(String[] args) {
        Frame frame = new Frame();
        Panel panel = new Panel();
        frame.setLayout(null);
        frame.setBounds(300, 300, 500, 500);
        frame.setBackground(Color.BLUE);
        //相对坐标
        panel.setBounds(50, 50, 200, 200);
        panel.setBackground(Color.RED);

        frame.add(panel);
        frame.setVisible(true);

        //监听
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }
}
